package com.weixing.mall.provider.controller.cms;


import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.core.support.auth.SysAuth;
import com.weixing.mall.core.support.auth.SysInfo;
import com.weixing.mall.provider.model.dto.cms.AgreementDto;
import com.weixing.mall.provider.service.IAgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统协议，主要包括申请成为代理商、申请成为会员，以及积分兑换等。 前端控制器
 * </p>
 *
 * @author 0202
 * @since 2020-05-28
 */
@RestController
@RequestMapping("agreement")
@Api(value = "后台:系统协议",tags = "后台:系统协议")
public class AgreementController extends BaseController {
    @Autowired
    private IAgreementService agreementService;

    @ApiOperation(value = "根据code更新对应内容")
    @PostMapping(value = "updateByCode")
    public Result updateByCode(@SysInfo SysAuth auth, @RequestBody AgreementDto agreementDto){
        agreementService.updateByCode(agreementDto.getCode(),agreementDto.getContent(),auth);
        return ResultUtil.success();
    }

    @ApiOperation(value = "根据code查询对应内容")
    @GetMapping(value = "getByCode/{code}")
    public Result getByCode(@PathVariable(value = "code") String code){
        return ResultUtil.success().setData(agreementService.getByCode(code));
    }

}
